package com.you.common.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableWebMvc
@EnableSwagger2
//@ComponentScan(basePackages = {"com.you.modules.user.controller"})
//@Configurable //配置注解，自动在本类上下文加载一些环境变量信息
public class SwaggerConfig extends WebMvcConfigurationSupport {

    @Bean
    public Docket customDocket() {
        return new Docket(DocumentationType.SWAGGER_2).select()// 选择哪些路径和API会生成document
            .apis(RequestHandlerSelectors.any())// 对所有api进行监控
            .paths(PathSelectors.any())// 对所有路径进行监控
            .build().apiInfo(apiInfo());
    }// */

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
            .title("SpringMVC中使用Swagger2整合")
            .termsOfServiceUrl("http://blog.csdn.net/zhang289202241")
            .description("springmvc swagger2")
            .contact(new Contact("张磊", "http://blog.csdn.net/zhang289202241", "289202241@qq.com"))
            .build();
    }


}
